import { JSEncrypt } from 'jsencrypt';


export function encrypt(data: string) {
  const publicKey = `MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuQd3gESx7VdIyRYUWjmjg61VIgUK6F45hClmqUMZ7xNiT5rlLM6e78osMvBF/yP7cVm7pK+NMCDWoVS1/AETpxJYqUlIC77ZAU8/MnP96IupnJL87vqhPcpdv7+VqLM38ls++yuD/F/HSoOQTv/leJh+dgE/4EYAJjOWFAbYfXwIDAQAB`;
  const enc = new JSEncrypt()
  enc.setPublicKey(publicKey)
  const cipher = enc.encrypt(data)
  if (!cipher) throw new Error('RSA 加密失败')
  return cipher
}
